package reflection.proxy;

import java.lang.reflect.Proxy;

/**
 * @author DuJiabao
 * @create 2021-01-12 22:48
 * 代理工厂
 */
public class ProxyFactory {
    public static Object getProxyInstance(Object obj) { // 输入被代理的对象
        MyInvocationHandler myInvocationHandler = new MyInvocationHandler(); // 调用句柄
        myInvocationHandler.bind(obj); // 绑定被代理对象
        return Proxy.newProxyInstance(obj.getClass().getClassLoader(), obj.getClass().getInterfaces(), myInvocationHandler);  // 返回代理对象
    }

}
